The present invention relates to computer graphics, and more particularly to mapping of depth values during computer graphics processing.
Generally, bump and texture mapping are rendering processes where basic contours of an object are expressed as graphics primitives (generally, polygons) with various types of data mapped onto graphics primitives. During the course of bump and texture mapping, a color calculation is performed to incorporate colors onto an object in display coordinate space. This object with the colors is then displayed on a display device.
Prior Art FIG. 1 illustrates the method by which an exemplary bump mapping process is accomplished. As shown, a primitive, i.e. polygon, triangle, etc., is first received with pixel data, as shown in operation 100. Included with such pixel data are normal values and possibly other values associated with the vertices associated with the polygon These vectors are perspectively and correctly interpolated across the primitive. At each pixel, texture coordinates (also interpolated) are used to look up bump mapping information.
During bump mapping, the aforementioned normal values are modified based on a bump map algorithm using the bump mapping information, as indicated in operation 102 of FIG. 1. In particular, the normal""s direction is perturbed as though the surface has been displaced a small amount in the direction of the interpolated normals of the primitive. FIG. 2 illustrates a primitive 200 with a normal 202 that is modified to generate a perturbed normal 204. A bumpy surface is thereby simulated.
Thereafter, lighting operations such as shading or the like are performed on the pixel data using the perturbed normal values instead of the original normal values, as indicated in operation 104. This method gives the appearance of bumps and depressions in the surface. Also at this time, the color calculation may be carried out in order to enhance the color of the pixel.
The foregoing bump and texture mapping processes are often supported by graphics application program interfaces (API""s). In one embodiment, such interface may include the Open Graphics Library (OpenGL(copyright)). OpenGL(copyright) is one of the computer industry""s standard application program interfaces (APIs) for defining 2-D and 3-D graphic images. An application can create the same effects in any operating system using any OpenGL(copyright)-adhering graphics adapter, provided the adapter supports the appropriate version of OpenGL(copyright) along with any utilized OpenGL(copyright) extensions. OpenGL(copyright) specifies a set of commands or immediately executed functions. Typically, a command directs a drawing action or causes special effects (e.g. bump and texture mapping processes).
Another API includes DirectX. Such API is provided by Microsoft(copyright) and is integral to the Windows(copyright) operating system. DirectX8(copyright) includes a xe2x80x9cpixel shadersxe2x80x9d functionality. DirectX""s(copyright) xe2x80x9cpixel shadersxe2x80x9d perform two particular tasks.
In a typical graphics pipeline, there is the task of interpolating texture coordinates and applying the texture mapping. This per-fragment task maps from interpolated floating-point texture coordinate sets to (typically fixed-point) texture unit RGBA results. In conventional OpenGL(copyright), this mapping is performed by accessing the highest priority enabled texture target using the fragment""s corresponding interpolated texture coordinate set. Unfortunately, this mapping is not very powerful.
Second, there is the task of fragment coloring. Fragment coloring is process of combining (typically fixed-point) RGBA colors to generate a final fragment color that, assuming the fragment is not discarded by subsequent per-fragment tests, is used to update the fragment""s corresponding pixel in the frame buffer. In conventional OpenGL(copyright), fragment coloring is performed by the enabled texture environment functions, fog, and color sum operations. NVIDIA""s(copyright) register combiners functionality (See the NV_register_combiners and NV_register_combiners2 extensions, which are incorporated herein by reference) provides a substantially more powerful alternative to conventional OpenGL(copyright) fragment coloring.
DirectX8(copyright) has two types of opcodes for pixel shaders. Texture address opcodes correspond to the first task listed above. Texture register opcodes correspond to the second task listed above.
While the foregoing bump and texture mapping techniques feature the unevenness of a surface and enhance the color of a pixel, they do not work well to reflect any unevenness in shadows cast by or onto the bumpy surface. Further, there are also limitations as to the interaction of geometric objects. These drawbacks are mainly due to the fact that conventional bump and texture mapping processes have no impact on the z-value of the pixel.
There is thus a need for a texture/bump mapping scheme during graphic processing that overcomes these drawbacks for providing a more realistic rendered image.
A system, method and computer program product are provided for computer graphics processing. Initially, a height parameter is determined. Thereafter, a depth-direction component of the height parameter is calculated. A depth-value of a pixel is then modified utilizing the computed depth-direction component of the height parameter.
In one embodiment, the height parameter may include a scalar and/or a vector. As an option, a plurality of height map values may be interpolated. Such height map values may be associated with a height map that is a component of a bump map including a plurality of elements each with a direction portion and a magnitude portion. In use, the depth-direction component of the height parameter may be computed based on the magnitude portion of one of the elements of the bump map. Optionally, the height map values may be interpolated from multiple multim in parvum (MIP) levels.
In another embodiment, an operation may be performed on the pixel taking into account the modified depth-value. Such operation may include a hidden surface calculation, a lighting operation, and/or a shadow mapping operation.
Another system, method and computer program product are provided for computer graphics processing. A height parameter is first determined. A normal for a pixel is also computer. The height parameter is dependent upon the normal. A depth-direction component of the height parameter is subsequently computed. In use, a depth value of the pixel is modified by utilizing the computed depth-direction component of the height parameter.
Still another system, method and computer program product are provided for texture shading in a hardware graphics processor. Initially, a plurality of texture coordinates is identified. It is then determined whether a hardware graphics processor is operating in a texture shader mode. If the hardware graphics processor is operating in the texture shader mode, the texture coordinates are mapped to colors utilizing a plurality of texture shader stages in the hardware graphics processor. If, however, the hardware graphics processor is not operating in the texture shader mode, the texture coordinates are mapped to colors utilizing a conventional graphics application program interface (API) in conjunction with the hardware graphics processor.
In one embodiment, each texture shader stage may execute a texture shader program. Moreover, each texture shader program may support dependent texture accesses, dot products, 3-D texture mapping, etc.
As an option, the texture shader programs may include NONE, TEXTURExe2x80x94b 1D, TEXTURExe2x80x942D, TEXTURE_RECTANGLE, TEXTURE_CUBE_MAP, PASS_THROUGH, CULL_FRAGMENT, OFFSET_TEXTURE, OFFSET_TEXTURExe2x80x942D_SCALE, OFFSET_TEXTURE_RECTANGLE, OFFSET_TEXTURE_RECTANGLE_SCALE, DEPENDENT_AR_TEXTURExe2x80x942D, DEPENDENT_GB_TEXTURExe2x80x942D, DOT_PRODUCT, DOT_PRODUCT_TEXTURExe2x80x942D, DOT_PRODUCT_TEXTURE_RECTANGLE, DOT_PRODUCT_TEXTURE_CUBE_MAP, DOT_PRODUCT_REFLECT_CUBE_MAP, DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP, DOT_PRODUCT_DIFFUSE_CUBE_MAP, and/or DOT_PRODUCT_DEPTH_REPLACE.
In another embodiment, the texture shading may be programmed by a user. Moreover, fragment shading operations may be performed utilizing the colors in order to generate results. Such results may include an RGBA color, a HILO value, a texture offset group, a floating-point value, and/or an invalid result. As an option, pixel shading operations may also be performed utilizing the results of the fragment shading operations.
To facilitate carrying out the foregoing functionality, a data structure may be stored in memory for texture shading in a hardware graphics processor. Included may be a control object for indicating whether the hardware graphics processor is operating in a texture shader mode. In use, a plurality of texture coordinates may be mapped to colors utilizing a plurality of texture shader stages in the hardware graphics processor, if the control object indicates that the hardware graphics processor is operating in the texture shader mode.
Still yet another system, method and computer program product are provided for bump mapping in a hardware graphics processor. Initially, a first set of texture coordinates is received. The texture coordinates are then multiplied by a matrix to generate results. A second set of texture coordinates is then offset utilizing the results. The offset second set of texture coordinates is then mapped to color.
As an option, the matrix may include a rotation matrix.